package com.demo;

import reactor.core.publisher.Mono;
import reactor.pool.InstrumentedPool;
import reactor.pool.PoolBuilder;
import reactor.pool.PoolConfig;
import reactor.pool.PooledRef;

public class Demo1 {

	public static void main(String[] args) {
		PoolBuilder<String, PoolConfig<String>> builder = PoolBuilder.from(Mono.just("a"))
				.sizeBetween(0, 100);
		InstrumentedPool<String> pool = builder.fifo();

		PooledRef<String> acquired1 = pool.acquire().block();
		System.out.println(acquired1.poolable());
		PooledRef<String> acquired2 = pool.acquire().block();
		System.out.println(acquired2.poolable());
		System.out.println(pool.metrics().acquiredSize());

		acquired1.release().block();
		acquired2.release().block();

		PooledRef<String> acquired3 = pool.acquire().block();
		System.out.println(acquired3.poolable());
		System.out.println(pool.metrics().acquiredSize());
	}

}
